#! /usr/bin/env bash

RED="\e[31m"
ENDCOLOR="\e[0m"

OUT_DIR="release"

rm -rf ${OUT_DIR}
mkdir ${OUT_DIR}

cd ${OUT_DIR} || exit 1

if ! cmake   -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo   ..; then
  echo -e "${RED}cmake error!${ENDCOLOR}" >&2
  exit 2
fi

if ! make -j16; then
  echo -e "${RED}compile error!${ENDCOLOR}" >&2
  exit 2
fi


if !  cmake --build . --target package ; then
  echo -e "${RED}package error!${ENDCOLOR}" >&2
  exit 2
fi
